﻿Imports System
Imports System.Workflow.ComponentModel.Design

Namespace System.Workflow.Activities
    <ActivityDesignerTheme(GetType(EventDrivenDesignerTheme))> _
    Friend NotInheritable Class EventDrivenDesigner
        Inherits SequenceDesigner
        ' Methods
        Public Overrides Function CanBeParentedTo(ByVal parentActivityDesigner As CompositeActivityDesigner) As Boolean
            If (parentActivityDesigner Is Nothing) Then
                Throw New ArgumentNullException("parentActivity")
            End If
            If ((Not Type.GetType("System.Workflow.Activities.ListenActivity,System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35").IsAssignableFrom(parentActivityDesigner.Activity.GetType) AndAlso Not TypeOf parentActivityDesigner.Activity Is EventHandlersActivity) AndAlso Not Type.GetType("System.Workflow.Activities.StateActivity,System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35").IsAssignableFrom(parentActivityDesigner.Activity.GetType)) Then
                Return False
            End If
            Return MyBase.CanBeParentedTo(parentActivityDesigner)
        End Function

        Protected Overrides Sub DoDefaultAction()
            MyBase.DoDefaultAction
            MyBase.EnsureVisible
        End Sub


        ' Properties
        Public Overrides ReadOnly Property CanExpandCollapse As Boolean
            Get
                If TypeOf MyBase.ParentDesigner Is StateDesigner Then
                    Return False
                End If
                Return MyBase.CanExpandCollapse
            End Get
        End Property

    End Class
End Namespace

